#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "CASE.h"
#include <malloc.h>

TABCASE caCreer_Case()
{

    TABCASE ta=(CASE*) malloc(41*sizeof(CASE));

    ta[1].num = 1;
    strcpy(ta[1].type , "départ");
    ta[1].x = 66;
    ta[1].y = 1137;

    ta[2].num = 2;
    strcpy(ta[2].type , "vide");
    ta[2].x = 66;
    ta[2].y = 1059;

    ta[3].num = 3;
    strcpy(ta[3].type , "vide");
    ta[3].x = 66;
    ta[3].y = 960;

    ta[4].num = 4;
    strcpy(ta[4].type ,  "question");
    ta[4].x = 66;
    ta[4].y = 873;

    ta[5].num = 5;
    strcpy(ta[5].type ,  "vide");
    ta[5].x = 66;
    ta[5].y = 780;

    ta[6].num = 6;
    strcpy(ta[6].type ,  "pieges");
    ta[6].x = 66;
    ta[6].y = 680;

    ta[7].num = 7;
    strcpy(ta[7].type,  "vide");
    ta[7].x = 66;
    ta[7].y = 590;

    ta[8].num = 8;
    strcpy(ta[8].type ,  "pieges");
    ta[8].x = 66;
    ta[8].y = 510;

    ta[9].num = 9;
    strcpy(ta[9].type ,  "vide");
    ta[9].x = 66;
    ta[9].y = 420;

    ta[10].num = 10;
    strcpy(ta[10].type ,  "question");
    ta[10].x = 66;
    ta[10].y = 320;

    ta[11].num = 11;
    strcpy(ta[11].type ,  "vide");
    ta[11].x = 66;
    ta[11].y = 234;

    ta[12].num = 12;
    strcpy(ta[12].type ,  "vide");
    ta[12].x = 159;
    ta[12].y = 234;

    ta[13].num = 13;
    strcpy(ta[13].type ,  "question");
    ta[13].x = 246;
    ta[13].y = 234;

    ta[14].num = 14;
    strcpy(ta[14].type ,  "vide");
    ta[14].x = 333;
    ta[14].y = 234;

    ta[15].num = 15;
    strcpy(ta[15].type ,  "pieges");
    ta[15].x = 411;
    ta[15].y = 234;

    ta[16].num = 16;
    strcpy(ta[16].type ,  "vide");
    ta[16].x = 507;
    ta[16].y = 234;

    ta[17].num = 17;
    strcpy(ta[17].type ,  "vide");
    ta[17].x = 591;
    ta[17].y = 234;

    ta[18].num = 18;
    strcpy(ta[18].type ,  "question");
    ta[18].x = 669;
    ta[18].y = 234;

    ta[19].num = 19;
    strcpy(ta[19].type ,  "vide");
    ta[19].x = 765;
    ta[19].y = 234;

    ta[20].num = 20;
    strcpy(ta[20].type ,  "tremplin");
    ta[20].x = 765;
    ta[20].y = 327;

    ta[21].num = 21;
    strcpy(ta[21].type ,  "vide");
    ta[21].x = 765;
    ta[21].y = 417;

    ta[22].num = 22;
    strcpy(ta[22].type ,  "vide");
    ta[22].x = 681;
    ta[22].y = 417;

    ta[23].num = 23;
    strcpy(ta[23].type ,  "vide");
    ta[23].x = 582;
    ta[23].y = 417;

    ta[24].num = 24;
    strcpy(ta[24].type ,  "question");
    ta[24].x = 504;
    ta[24].y = 417;

    ta[25].num = 25;
    strcpy(ta[25].type ,  "vide");
    ta[25].x = 414;
    ta[25].y = 417;

    ta[26].num = 26;
    strcpy(ta[26].type ,  "pieges");
    ta[26].x = 330;
    ta[26].y = 417;

    ta[27].num = 27;
    strcpy(ta[27].type ,  "vide");
    ta[27].x = 249;
    ta[27].y = 417;

    ta[28].num = 28;
    strcpy(ta[28].type ,  "tempete");
    ta[28].x = 249;
    ta[28].y = 510;

    ta[29].num = 29;
    strcpy(ta[29].type ,  "vide");
    ta[29].x = 249;
    ta[29].y = 600;

    ta[30].num = 30;
    strcpy(ta[30].type ,  "vide");
    ta[30].x = 336;
    ta[30].y = 600;

    ta[31].num = 31;
    strcpy(ta[31].type ,  "question");
    ta[31].x = 411;
    ta[31].y = 600;

    ta[32].num = 32;
    strcpy(ta[32].type ,  "vide");
    ta[32].x = 501;
    ta[32].y = 600;

    ta[33].num = 33;
    strcpy(ta[33].type ,  "piege");
    ta[33].x = 488;
    ta[33].y = 600;

    ta[34].num = 34;
    strcpy(ta[34].type ,  "vide");
    ta[34].x = 678;
    ta[34].y = 600;

    ta[35].num = 35;
    strcpy(ta[35].type ,  "tremplin");
    ta[35].x = 765;
    ta[35].y = 600;

    ta[36].num = 36;
    strcpy(ta[36].type ,  "vide");
    ta[36].x = 765;
    ta[36].y = 680;

    ta[37].num = 37;
    strcpy(ta[37].type ,  "vide");
    ta[37].x = 765;
    ta[37].y = 793;

    ta[38].num = 38;
    strcpy(ta[38].type ,  "quesition");
    ta[38].x = 672;
    ta[38].y = 793;

    ta[39].num = 39;
    strcpy(ta[39].type ,  "pieges");
    ta[39].x = 585;
    ta[39].y = 793;

    ta[40].num = 40;
    strcpy(ta[40].type ,  "vide");
    ta[40].x = 507;
    ta[40].y = 793;

    ta[41].num = 41;
    strcpy(ta[41].type ,  "vide");
    ta[41].x = 414;
    ta[41].y = 793;

   ta[42].num = 42;
   strcpy(ta[42].type ,  "vide");
   ta[42].x = 333;
   ta[42].y = 793;

   ta[43].num = 43;
   strcpy(ta[43].type ,  "vide");
   ta[43].x = 243;
   ta[43].y = 793;

   ta[44].num = 44;
   strcpy(ta[44].type ,  "tremplin");
   ta[44].x = 243;
   ta[44].y = 882;

   ta[45].num = 45;
   strcpy(ta[45].type ,  "tempete");
   ta[45].x = 243;
   ta[45].y = 969;

   ta[46].num = 46;
   strcpy(ta[46].type ,  "tremplin");
   ta[46].x = 333;
   ta[46].y = 969;

   ta[47].num = 47;
   strcpy(ta[47].type ,  "vide");
   ta[47].x = 414;
   ta[47].y = 969;

   ta[48].num = 48;
   strcpy(ta[48].type ,  "question");
   ta[48].x = 504;
   ta[48].y = 969;

   ta[49].num = 49;
   strcpy(ta[49].type ,  "vide");
   ta[49].x = 590;
   ta[49].y = 969;

   ta[50].num = 50;
   strcpy(ta[50].type ,  "tempete");
   ta[50].x = 675;
   ta[50].y = 969;

   ta[51].num = 51;
   strcpy(ta[51].type ,  "vide");
   ta[51].x = 775;
   ta[51].y = 969;

   ta[52].num = 52;
   strcpy(ta[52].type ,  "pieges");
   ta[52].x = 775;
   ta[52].y = 1059;

   ta[53].num = 53;
   strcpy(ta[53].type ,  "vide");
   ta[53].x = 775;
   ta[53].y = 1140;

   ta[54].num = 54;
   strcpy(ta[54].type ,  "vide");
   ta[54].x = 681;
   ta[54].y = 1140;

   ta[55].num = 55;
   strcpy(ta[55].type ,  "question");
   ta[55].x = 582;
   ta[55].y = 1140;

   ta[56].num = 56;
   strcpy(ta[56].type ,  "vide");
   ta[56].x = 501;
   ta[56].y = 1140;

   ta[57].num = 57;
   strcpy(ta[57].type ,  "tempete");
   ta[57].x = 417;
   ta[57].y = 1140;

   ta[58].num = 58;
   strcpy(ta[58].type ,  "vide");
   ta[58].x = 324;
   ta[58].y = 1140;

   ta[59].num = 59;
   strcpy(ta[59].type ,  "arrive");
   ta[59].x = 234;
   ta[59].y = 1140;

    return ta;
}

void caLibere_case(TABCASE* ca)
{
    int i;
    for (i=1; i<=40; i++)
    {
        free (ca[i]);
    }
}

void caTest_Case()
{
    TABCASE ca;
    int i;
    ca = caCreer_Case();
    printf("Tests du module CASE : \n\n") ;
    /* Début du test de caCreer_Case*/
    printf("Test de caCreer_Case ... \n") ;
    for(i=1; i<=59; i++)
    {
        assert(ca[i].num== i);
        assert(!(strcmp(ca[i].type, "")));
        assert(ca[i].x != 0);
        assert(ca[i].y != 0);
    }
    assert(i==59);
    caLibere_case(&ca);
    printf("Tests du module CASE terminé \n\n") ;
}
